<template>
  <div>
    <fm-generate-form ref="generateForm" :data="jsonData" />
    <el-button type="primary" @click="handleSubmit">Submit</el-button>
  </div>
</template>

<script>
export default {
  name: 'FormMaking',
  data() {
    return {
      jsonData: {
        list: [
          {
            type: 'input',
            icon: 'icon-input',
            options: {
              width: '100%',
              defaultValue: '',
              required: false,
              dataType: 'string',
              pattern: '',
              placeholder: '',
              customClass: '',
              disabled: false,
              labelWidth: 100,
              isLabelWidth: false,
              hidden: false,
              dataBind: true,
              showPassword: false,
              remoteFunc: 'func_1575897887618',
              remoteOption: 'option_1575897887618'
            },
            name: '单行文本',
            key: '1575897887618',
            model: 'input_1575897887618',
            rules: [{ type: 'string', message: '单行文本格式不正确' }]
          }
        ],
        config: {
          labelWidth: 100,
          labelPosition: 'right',
          size: 'small',
          customClass: ''
        }
      }
    }
  },
  methods: {
    handleSubmit() {
      this.$refs.generateForm
        .getData()
        .then(data => {
          alert(JSON.stringify(data))
        })
        .catch(e => {})
    }
  }
}
</script>
